package cn.exrick.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.exrick.mapper.TbPreferentialMapper;
import cn.exrick.pojo.TbPreferential;
import cn.exrick.service.PreferentialService;
import cn.exrick.utils.mybatis.Criteria;

@Service
public class PreferentialServiceImpl extends BaseServiceImpl<TbPreferential, TbPreferentialMapper> implements PreferentialService {
    private final static Logger log = LoggerFactory.getLogger(PreferentialServiceImpl.class);

    @Override
    public Logger getLogger() {
        return log;
    }

    public Criteria createCriteria(Map<String, Object> params) {
        Criteria criteria = createCriteria();
        if (params.get("money") != null) {
            criteria.andFieldEqualTo("money", String.valueOf((Double) params.get("money")));
        }
        if (params.get("num") != null) {
            criteria.andFieldEqualTo("num", String.valueOf((Integer) params.get("num")));
        }
        if (params.get("total") != null) {
            criteria.andFieldEqualTo("total", String.valueOf((Double) params.get("total")));
        }
        if (params.get("price") != null) {
            criteria.andFieldEqualTo("price", String.valueOf((Double) params.get("price")));
        }
        return criteria;
    }

    @Autowired
    TbPreferentialMapper tbPreferentialMapper;

    @Override
    public TbPreferentialMapper getMapper() {
        return tbPreferentialMapper;
    }

    @Override
    public List<TbPreferential> findByItemId(long itemId) {
        return null;
    }
}
